import {
	config
} from "../config.js";

async function mypost(url, data) {

	return new Promise((resolve, reject) => {
		uni.request({
			url: config.baseUrl + url,
			data: {
				uid: uni.getStorageSync('user') ? uni.getStorageSync('user').id : '',
				...data
			},
			timeout: "5000",
			method: "POST",
			sslVerify: false,
			success(res) {
				resolve(res)
			},
			fail(e) {
		
				console.log(e)
			}
		})
	})
}
async function myget(url, data) {
	return new Promise((resolve, reject) => {
		uni.request({
			url: config.baseUrl + url,
			data: data,
			sslVerify: false,
			method: "GET",
			success(res) {
				resolve(res)
			},
		})
	})
}
async function login( data){//登陆
    return await mypost('/user/login',data);
}
async function registration( data){//注册
    return await mypost('/newUser/registration',data);
}
async function verification( data){//验证code
    return await mypost('/user/fogotPass/verification',data);
}
async function fogotPass( data){//忘记密码发送验证
    return await mypost('/user/fogotPass',data);
}
async function reset( data){//忘记密码发送验证
    return await mypost('/user/password/reset',data);
}
async function visitor( data){//添加至本销售客户列表
    return await mypost('/user/new/visitor,',data);
}
async function searchedVistor( data){//根据手机号 或者手机号后四位进行索引（或者姓名等）
    return await mypost('/user/searchedVistor,,',data);
}

// /user/fogotPass/verification,
export{
	login,
	registration,
	verification,
	fogotPass,
	reset,
	visitor,
	searchedVistor
}